package com.shop2cn.iapi.productcategory.testcase;

import com.shop2cn.iapi.productcategory.parameter.BrandDto;
import com.shop2cn.iapi.productcategory.parameter.GetBrandByIdBean;
import com.shop2cn.iapi.productcategory.service.GetBrandByIdCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.mongo.BuyerProductShop2cnWapper;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.ArrayList;
import java.util.Map;
/**
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetBrandById{
	private static GetBrandByIdBean GetBrandByIdBean;
	private static GetBrandByIdCall GetBrandByIdCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据品牌Id获取品牌信息");
	}

	@Before
	public void caseUp() {
		GetBrandByIdBean=new GetBrandByIdBean();
		//新站点
		GetBrandByIdCall=new GetBrandByIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetBrandByIdCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBrandById_001() {
		Logger.start(true,"根据品牌Id获取品牌信息成功");
		try {
			BuyerProductShop2cnWapper pbinfow = new BuyerProductShop2cnWapper();
			ArrayList<Map> list = pbinfow.getProductBrandInfos(1);
			Map map = list.get(0);
			GetBrandByIdBean.setBrandId(map.get("BrandId").toString());
			GetBrandByIdCall.setData(GetBrandByIdBean);
			GetBrandByIdCall.callService();			
			Logger.verifyEquals("200", GetBrandByIdCall.getString("Code"), "验证Code");
			BrandDto Brand=(BrandDto) FormatUtil.GSONToObject(GetBrandByIdCall.getJsonObject().get("Data").getAsJsonObject().get("Brand").toString(), BrandDto.class);
//			{_id=57ac3d1e6ec5d61c65f45864, BrandId=10060, BrandName=, BrandEnName=Abercrombie&Fitch, KeyWord=A, ProductCount=0, Alias=, BrandLogoUrl=, BrandBannerUrl=, BrandDescription=A&F (Abercrombie&Fitch) 服饰品牌从美国风行全世界，主要走休闲年轻路线。衣服质感超佳、设计出众，适合亚洲人的体型非常抢手。服装采用上等的全棉面料，舒适透气，手感柔软，吸汗性也更胜一筹。 A&F (Abercrombie&Fitch) 越来越流行，但定价并不便宜，堪称高级运动服。在美国如果身上穿著一件 A&F (Abercrombie&Fitch) ，可以算是小贵族啦。A&F (Abercrombie&Fitch) 是一个美国本土品牌，还没有开放给其他国家。想要买 A&F (Abercrombie&Fitch) 的衣服只有上网找代购。, 
			//BrandDescriptionEn=, Attention=0, Level=5, BrandBizSector=, Action=0, CreateTime=Wed Apr 14 13:17:00 CST 2010, CreateUser=, UpdateTime=Wed Apr 14 13:17:00 CST 2010, UpdateUser=}
			Logger.verifyEquals(map.get("BrandId"), Brand.getBrandId(), "验证Brandid");
			Logger.verifyEquals(map.get("BrandName"), Brand.getBrandName(), "验证BrandName");
			Logger.verifyEquals(map.get("BrandEnName"), Brand.getBrandEnName(), "验证BrandEnName");
			Logger.verifyEquals(map.get("KeyWord"), Brand.getKeyWord(), "验证KeyWord");
			Logger.verifyEquals(map.get("ProductCount"), Brand.getProductCount(), "验证ProductCount");
			Logger.verifyEquals(map.get("Alias"), Brand.getAlias(), "验证Alias");
			Logger.verifyEquals(map.get("BrandLogoUrl"), Brand.getBrandLogoUrl(), "验证BrandLogoUrl");
			Logger.verifyEquals(map.get("BrandBannerUrl"), Brand.getBrandBannerUrl(), "验证BrandBannerUrl");
			Logger.verifyEquals(map.get("BrandDescription"), Brand.getBrandDescription(), "验证BrandDescription");
			Logger.verifyEquals(map.get("BrandDescriptionEn"), Brand.getBrandDescriptionEn(), "验证BrandDescriptionEn");
			//Attention?
			//Action?
			Logger.verifyEquals(map.get("Level"), Brand.getLevel(), "验证Level");
			Logger.verifyEquals(map.get("BrandBizSector"), Brand.getBrandBizSector(), "验证BrandBizSector");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}